Re: [swift-users] Generic inheritance with where clause

2017-08-29 Thread somu subscribe via swift-users
Hi Nikita,

See if the below implementation fits your needs:

protocol P1 {}

protocol P2 : P1 where T : P1 {

associatedtype T

var input : T { get }
}

struct S1 : P1 {}

struct S2 : P2 {

typealias T = S1

var input: T
}

Regards,
Muthu


> On 30 Aug 2017, at 1:25 AM, Nikita Leonov via swift-users 
>  wrote:
> 
> Hello everyone, 
> 
> I am looking a way to express something similar to the following code in 
> Swift terms:
> protocol AnyViewModelInput {}
> protocol AnyViewModel: ViewModelInput where ViewModelInput: 
> AnyViewModelInput {
> var input: ViewModelInput { get }
> }
> 
> Is it possible in current Swift? Will it be possible if generic manifesto 
> will be implemented in full? Also if you know how to express a similar idea 
> in any other language, I would love to see examples. How does such construct 
> is named in other languages?
> 
> Thank in advance,
> Nikita
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Build toolchain failure for swift-4.0-branch on Mac OSX 10.12.6

2017-08-29 Thread Mishal Shah via swift-users
Adding swift-lldb-dev group. 

Thanks,
Mishal Shah

> On Aug 29, 2017, at 4:00 PM, Raj Barik via swift-users 
>  wrote:
> 
> OSx version: 10.12.6 (16G29)
> Steps to reproduce the error:
> 1)
> git clone https://github.com/apple/swift.git 
> 
> ./swift/utils/update-checkout --clone --scheme swift-4.0-branch
> 2) Edit build-preset.ini to remove tests and assertions:
> 
> [preset: mixin_lightweight_assertions]
> #assertions
> #no-swift-stdlib-assertions
> no-assertions
> swift-assertions
> 
> 
> [preset: buildbot_osx_package]
> mixin-preset=
> mixin_osx_package_base
> mixin_lightweight_assertions
> ...
> 
> 3) Execute: ./swift/util/build-toolchain local.swift
> 
> Error:
> 
> /bin/sh -c 
> $HOME/swift-4.0/build/Ninja+cmark-RelWithDebInfo+llvm-RelWithDebInfo+swift-RelWithDebInfoAssert+stdlib-RelWithDebInfo/lldb-macosx-x86_64/lldb.build/CustomSwift-Release/lldb-core.build/Script-261EECA21337D399001D193C.sh
> + '[' CustomSwift-Release == 'CustomSwift-*' ']'
> + /usr/bin/env python $HOME/swift-4.0/lldb/scripts/Xcode/build-llvm.py
> Traceback (most recent call last):
>   File "$HOME/swift-4.0/lldb/scripts/Xcode/build-llvm.py", line 355, in 
> 
> write_archives_txt()
>   File "$HOME/swift-4.0/lldb/scripts/Xcode/build-llvm.py", line 107, in 
> write_archives_txt
> for archive in archive_list():
>   File "$HOME/swift-4.0/lldb/scripts/Xcode/build-llvm.py", line 101, in 
> archive_list
> archive_lists = [collect_archives_in_path(path) for path in paths]
>   File "$HOME/swift-4.0/lldb/scripts/Xcode/build-llvm.py", line 85, in 
> collect_archives_in_path
> files = os.listdir(path)
> OSError: [Errno 2] No such file or directory: 
> '$HOME/swift-4.0/build/Ninja+cmark-RelWithDebInfo+llvm-RelWithDebInfo+swift-RelWithDebInfoAssert+stdlib-RelWithDebInfo/llvm-macosx-x86_64/src'
> Command /bin/sh failed with exit code 1
> 
> ** BUILD FAILED **
> 
> 
> The following build commands failed:
>   PhaseScriptExecution Build\ llvm\ and\ clang 
> $HOME/swift-4.0/build/Ninja+cmark-RelWithDebInfo+llvm-RelWithDebInfo+swift-RelWithDebInfoAssert+stdlib-RelWithDebInfo/lldb-macosx-x86_64/lldb.build/CustomSwift-Release/lldb-core.build/Script-261EECA21337D399001D193C.sh
> (1 failure)
> ./utils/build-script: fatal error: command terminated with a non-zero exit 
> status 65, aborting
> ./utils/build-script: fatal error: command terminated with a non-zero exit 
> status 1, aborting
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Module verifier error with master branch

2017-08-29 Thread Raj Barik via swift-users
OS: 10.12.6 (16G29)

Steps:
1) Checkout swift and build master branch
   git clone https://github.com/apple/swift.git
   ./swift/utils/update-checkout --clone

2) Edit swift/utils/build-presets.ini to remove tests
   [preset: buildbot_osx_package]
   mixin-preset=
mixin_osx_package_base
mixin_lightweight_assertions
...
3) Execute ./swift/utils/build-toolchain local.swift

4) Execute n sample swift package in Xcode:

Error:

Invalid bitcast

  %195 = bitcast i64 %194 to %objc_object*, !dbg !431

Invalid bitcast

  %256 = bitcast i64 %255 to %objc_object*, !dbg !443

:0: error: fatal error encountered during compilation; please file
a bug report with your project and the crash log

:0: note: Broken function found, compilation aborted!

0  swiftc   0x00010955ebc8
llvm::sys::PrintStackTrace(llvm::raw_ostream&)
+ 40

1  swiftc   0x00010955def6
llvm::sys::RunSignalHandlers() + 86

2  swiftc   0x00010955f12e SignalHandler(int) + 270

3  libsystem_platform.dylib 0x7fffbb08cb3a _sigtramp + 26

4  libsystem_platform.dylib 0x7b4115a0 _sigtramp + 1345866368

5  libsystem_c.dylib0x7fffbaf11420 abort + 129

6  swiftc   0x0001067985c7
swift::performFrontend(llvm::ArrayRef, char const*, void*, swift::FrontendObserver*)::$_0::__invoke(void*,
std::__1::basic_string const&, bool) + 551

7  swiftc   0x000109506cac
llvm::report_fatal_error(llvm::Twine const&, bool) + 252

8  swiftc   0x000109506baa
llvm::report_fatal_error(char const*, bool) + 42

9  swiftc   0x0001094c0d06 (anonymous namespace)::
VerifierLegacyPass::runOnFunction(llvm::Function&) + 54

10 swiftc   0x000109466b22
llvm::FPPassManager::runOnFunction(llvm::Function&)
+ 498

11 swiftc   0x0001094663b9 llvm::legacy::
FunctionPassManagerImpl::run(llvm::Function&) + 169

12 swiftc   0x00010946627a llvm::legacy::
FunctionPassManager::run(llvm::Function&) + 362

13 swiftc   0x000106893e02 swift::
performLLVMOptimizations(swift::IRGenOptions&, llvm::Module*,
llvm::TargetMachine*) + 1410

14 swiftc   0x000106894736
swift::performLLVM(swift::IRGenOptions&,
swift::DiagnosticEngine*, llvm::sys::SmartMutex*,
llvm::GlobalVariable*, llvm::Module*, llvm::TargetMachine*,
swift::version::Version const&, llvm::StringRef,
swift::UnifiedStatsReporter*) + 1574

15 swiftc   0x0001068993c9
ThreadEntryPoint(swift::irgen::IRGenerator*, llvm::sys::SmartMutex*,
int) + 249

16 swiftc   0x000106899fff void*
std::__1::__thread_proxy, void
(*)(swift::irgen::IRGenerator*, llvm::sys::SmartMutex*, int),
swift::irgen::IRGenerator*, llvm::sys::SmartMutex*, int> >(void*) +
47

17 libsystem_pthread.dylib  0x7fffbb09693b _pthread_body + 180

18 libsystem_pthread.dylib  0x7fffbb096887 _pthread_body + 0

19 libsystem_pthread.dylib  0x7fffbb09608d thread_start + 13

Stack dump:

0. Running pass 'Module Verifier' on function '@_FUNCTION_NAME_'


Does anyone know how to turn off module verifier or fix the above error (I
do not see the "-disable-llvm-verify" option with swift/swiftc command
line)?
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Build toolchain failure for swift-4.0-branch on Mac OSX 10.12.6

2017-08-29 Thread Raj Barik via swift-users
OSx version: 10.12.6 (16G29)
Steps to reproduce the error:
1)

git clone https://github.com/apple/swift.git
./swift/utils/update-checkout --clone --scheme swift-4.0-branch

2) Edit build-preset.ini to remove tests and assertions:

[preset: mixin_lightweight_assertions]
#assertions
#no-swift-stdlib-assertions
no-assertions
swift-assertions


[preset: buildbot_osx_package]
mixin-preset=
mixin_osx_package_base
mixin_lightweight_assertions
...

3) Execute: ./swift/util/build-toolchain local.swift

Error:

/bin/sh -c $HOME/swift-4.0/build/Ninja+cmark-RelWithDebInfo+llvm-
RelWithDebInfo+swift-RelWithDebInfoAssert+stdlib-RelWithDebInfo/lldb-macosx-
x86_64/lldb.build/CustomSwift-Release/lldb-core.build/Script-
261EECA21337D399001D193C.sh
+ '[' CustomSwift-Release == 'CustomSwift-*' ']'
+ /usr/bin/env python $HOME/swift-4.0/lldb/scripts/Xcode/build-llvm.py
Traceback (most recent call last):
  File "$HOME/swift-4.0/lldb/scripts/Xcode/build-llvm.py", line 355, in

write_archives_txt()
  File "$HOME/swift-4.0/lldb/scripts/Xcode/build-llvm.py", line 107, in
write_archives_txt
for archive in archive_list():
  File "$HOME/swift-4.0/lldb/scripts/Xcode/build-llvm.py", line 101, in
archive_list
archive_lists = [collect_archives_in_path(path) for path in paths]
  File "$HOME/swift-4.0/lldb/scripts/Xcode/build-llvm.py", line 85, in
collect_archives_in_path
files = os.listdir(path)
OSError: [Errno 2] No such file or directory: '$HOME/swift-4.0/build/Ninja+
cmark-RelWithDebInfo+llvm-RelWithDebInfo+swift-RelWithDebInfoAssert+stdlib-
RelWithDebInfo/llvm-macosx-x86_64/src'
Command /bin/sh failed with exit code 1

** BUILD FAILED **


The following build commands failed:
PhaseScriptExecution Build\ llvm\ and\ clang $HOME/swift-4.0/build/Ninja+
cmark-RelWithDebInfo+llvm-RelWithDebInfo+swift-RelWithDebInfoAssert+stdlib-
RelWithDebInfo/lldb-macosx-x86_64/lldb.build/CustomSwift-
Release/lldb-core.build/Script-261EECA21337D399001D193C.sh
(1 failure)
./utils/build-script: fatal error: command terminated with a non-zero exit
status 65, aborting
./utils/build-script: fatal error: command terminated with a non-zero exit
status 1, aborting
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] SwiftPM on Linux Failed

2017-08-29 Thread Ankit Aggarwal via swift-users
Hey,

Can you post the steps you followed to install the Swift toolchain?

Also, can you post the output of:
$ swift build -v

Thanks!

On Tue, Aug 29, 2017 at 8:14 PM, adelzhang via swift-users <
swift-users@swift.org> wrote:

>
> Hi, everyone.
>
> Installing swift on linux is not that easy. Following
> https://swift.org/getting-started/#using-the-package-manager instruction,
> but `swift build` failed:
>
> ```
> error: manifest parse error(s):
> /home/vagrant/hello/Package.swift:4:8: error: no such module
> 'PackageDescription'
> import PackageDescription
>^
> ```
>
> I installed Swift 4.0
>
> ```
> $swift version
> Swift version 4.0-dev (LLVM 2dedb62a0b, Clang b9d76a314c, Swift 0899bd328a)
> Target: x86_64-unknown-linux-gnu
> ```
>
> Ubuntu 14.04 is running on VirtualBox using vagrant.
>
> ```
> $lsb_release -a
> No LSB modules are available.
> Distributor ID: Ubuntu
> Description:Ubuntu 14.04.5 LTS
> Release:14.04
> Codename:   trusty
> ```
>
> Does someone happen to know the work-around?
>
> --
> Regards
>
> adelzhang
>
>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Still can't derive from a generic class

2017-08-29 Thread Joanna Carter via swift-users
Hi Jon

> Le 29 août 2017 à 19:20, Jon Shier  a écrit :
> 
> This works fine for me in a playground in the latest Xcode 9 beta:
> 
> class Test { }
> 
> class Base { }
> 
> class Sub: Base { }
> 
> let sub = Sub()

That may well work but what I want is to be able to do is simpler than that :

class Base { }

class Test : Base { }

let test = Test()


Joanna

--
Joanna Carter
Carter Consulting

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Generic inheritance with where clause

2017-08-29 Thread Nikita Leonov via swift-users
Hello everyone,

I am looking a way to express something similar to the following code in
Swift terms:
protocol AnyViewModelInput {}
protocol AnyViewModel: ViewModelInput where ViewModelInput:
AnyViewModelInput {
var input: ViewModelInput { get }
}

Is it possible in current Swift? Will it be possible if generic
manifesto will be implemented in full? Also if you know how to express a
similar idea in any other language, I would love to see examples. How does
such construct is named in other languages?

Thank in advance,
Nikita
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Still can't derive from a generic class

2017-08-29 Thread Jon Shier via swift-users
This works fine for me in a playground in the latest Xcode 9 beta:

class Test { }

class Base { }

class Sub: Base { }

let sub = Sub()



Jon


> On Aug 29, 2017, at 1:04 PM, Joanna Carter via swift-users 
>  wrote:
> 
> Hi
> 
> I would have hoped by now that it should be possible to do :
> 
> class BaseObject
> {
> }
> 
> class Test : BaseObject
> {
> }
> 
> All compiles well but, at runtime, when calling let test = Test(), I get a 
> "EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)" error.
> 
> This is something I have been able to do in C# for many a year. Why oh why 
> can I still not do it in Swift ?
> 
> Joanna
> 
> --
> Joanna Carter
> Carter Consulting
> 
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Still can't derive from a generic class

2017-08-29 Thread Joanna Carter via swift-users
Hi

I would have hoped by now that it should be possible to do :

class BaseObject
{
}

class Test : BaseObject
{
}

All compiles well but, at runtime, when calling let test = Test(), I get a 
"EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)" error.

This is something I have been able to do in C# for many a year. Why oh why can 
I still not do it in Swift ?

Joanna

--
Joanna Carter
Carter Consulting

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Generic inheritance with where clause

2017-08-29 Thread Nikita Leonov via swift-users
Hello everyone,

I am looking a way to express something similar to the following code in
Swift terms:
protocol AnyViewModelInput {}
protocol AnyViewModel: ViewModelInput where ViewModelInput:
AnyViewModelInput {
var input: ViewModelInput { get }
}

Such construct supposed to avoid code duplications as follows and reuse
code for splitting view models its inputs etc:
protocol FooViewModelInput {
var foo: Int { get set }
}

protocol FooViewModelProtocol: FooViewModelInput {
var input: FooViewModelInput { get }
}

final class FooViewModel: FooViewModelProtocol {
var input: FooViewModelInput {
return self
}
var foo = 0
}

Is it possible in current Swift? Will it be possible if generic
manifesto will be implemented in full? Also if you know how to express a
similar idea in any other language, I would love to see examples. How does
such construct is named in other languages?

Thank in advance,
Nikita
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] SwiftPM on Linux Failed

2017-08-29 Thread adelzhang via swift-users


Hi, everyone.

Installing swift on linux is not that easy. Following  
https://swift.org/getting-started/#using-the-package-manager instruction,  
but `swift build` failed:


```
error: manifest parse error(s):
/home/vagrant/hello/Package.swift:4:8: error: no such module  
'PackageDescription'

import PackageDescription
   ^
```

I installed Swift 4.0

```
$swift version
Swift version 4.0-dev (LLVM 2dedb62a0b, Clang b9d76a314c, Swift 0899bd328a)
Target: x86_64-unknown-linux-gnu
```

Ubuntu 14.04 is running on VirtualBox using vagrant.

```
$lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:Ubuntu 14.04.5 LTS
Release:14.04
Codename:   trusty
```

Does someone happen to know the work-around?

--
Regards

adelzhang


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users