[swift-dev] Compiler crash - relates to protocol and protocol extension

Dmitri Gribenko gribozavr at gmail.com
Mon Dec 21 11:20:14 CST 2015


On Sun, Dec 20, 2015 at 4:42 AM, Jasl via swift-dev <swift-dev at swift.org>
wrote:

> Hi,
>
> I found a piece of code that could made the compiler crash, It’s can
> reproduce on Xcode 7.2(7C68) with Apple Swift version 2.1.1
> (swiftlang-700.1.101.15 clang-700.1.81) Target: x86_64-apple-darwin15.2.0
>
> the code is simply like:
>
> protocol FooType {
>   func bar(b: Int)
> }
>
> extension FooType {
>   func bar(a: Int, b: Int) {
>   }
> }
>
> struct Foo: FooType {
>
> }
>

Hi Jasl,

This example does not seem to crash in current master branch:

swiftc a.swift
a.swift:10:8: error: type 'Foo' does not conform to protocol 'FooType'
struct Foo: FooType {
       ^
a.swift:2:8: note: protocol requires function 'bar' with type '(Int) -> ()'
  func bar(b: Int)
       ^
a.swift:6:8: note: candidate has non-matching type '<Self> (Int, b: Int) ->
()' (aka '<τ_0_0> (Int, b: Int) -> ()')
  func bar(a: Int, b: Int) {
       ^

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20151221/70314e10/attachment.html>


More information about the swift-dev mailing list