Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spurious type error in super constructor call under -Xexperimental (since sammy merge) #9141

Closed
scabug opened this issue Feb 9, 2015 · 6 comments
Labels

Comments

@scabug
Copy link

scabug commented Feb 9, 2015

class A(stream: java.io.InputStream)
class B(url: java.net.URL) extends A(url.openStream)

Distilled from ProcessBuilderImpl.scala in the stdlib.

Regressed in scala/scala@9c36a7617

% scalac-hash 9c36a7617~1 -Xexperimental sandbox/test.scala

% scalac-hash 9c36a7617 -Xexperimental sandbox/test.scala
sandbox/test.scala:2: error: type mismatch;
 found   : java.io.InputStream
 required: Int
class B(url: java.net.URL) extends A(url.openStream)
                                         ^
one error found
@scabug
Copy link
Author

scabug commented Feb 9, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9141?orig=1
Reporter: @retronym
Affected Versions: 2.11.5
See #9178

@scabug
Copy link
Author

scabug commented Mar 3, 2015

@adriaanm said:
Interesting, under -Xexperimental:

scala> samOf(typeOf[java.io.InputStream])
res1: $r.intp.global.Symbol = method read

and -Ytyper-debug on the example says:

|    |    |-- { super.<init>(url.openStream); () } EXPRmode (site: <init> in B) 
|    |    |    |-- super.<init>(url.openStream) BYVALmode-EXPRmode (site: <init> in B) 
|    |    |    |    |-- super EXPRmode-POLYmode-QUALmode (silent: <init> in B) 
|    |    |    |    |    |-- this EXPRmode (silent: <init> in B) 
|    |    |    |    |    |    \-> B
|    |    |    |    |    \-> B.super.type (with underlying type A)
|    |    |    |    |-- url.openStream : pt=java.io.InputStream BYVALmode-EXPRmode (site: <init> in <empty>) 
|    |    |    |    |    |-- url EXPRmode-POLYmode-QUALmode (site: <init> in <empty>) 
|    |    |    |    |    |    \-> url.type (with underlying type java.net.URL)
|    |    |    |    |    |-- { (() => url.openStream()) } : pt=java.io.InputStream BYVALmode-EXPRmode (site: <init> in <empty>) 
|    |    |    |    |    |    |-- (() => url.openStream()) : pt=java.io.InputStream BYVALmode-EXPRmode (site: <init> in <empty>) 
|    |    |    |    |    |    |    |-- { def read$body(): Int = url.openStream(); final class $a... : pt=java.io.InputStream BYVALmode-EXPRmode (site: <init> in <empty>) 
|    |    |    |    |    |    |    |    |-- def read$body BYVALmode-EXPRmode (site: <init> in <empty>) 
|    |    |    |    |    |    |    |    |    |-- url.openStream() : pt=Int EXPRmode (site: method read$body in <empty>) 
|    |    |    |    |    |    |    |    |    |    |-- url.openStream BYVALmode-EXPRmode-FUNmode-POLYmode (silent: method read$body in <empty>) 
|    |    |    |    |    |    |    |    |    |    |    \-> ()java.io.InputStream
/Users/adriaan/Desktop/bugs/t9141.scala:2: error: type mismatch;
 found   : java.io.InputStream
 required: Int
class B(url: java.net.URL) extends A(url.openStream)
                                         ^

@scabug
Copy link
Author

scabug commented Mar 3, 2015

@adriaanm said:
This raises an interesting question about the order of implicit conversions. Particularly, eta-expansion and empty application. I seem to remember someone bringing this up recently.

The reason this doesn't type-check under -Xexperimental is because it meets the criteria for eta-expansion as defined at http://scala-lang.org/files/archive/spec/2.11/06-expressions.html#eta-expansion (where "function type" is generalized to include sam types). Without -Xexperimental, it went straight to "empty application".

@scabug
Copy link
Author

scabug commented Mar 3, 2015

@adriaanm said:
And by "recently" I mean something like 1964 bugs ago: #7187

@scabug
Copy link
Author

scabug commented Mar 3, 2015

@retronym said:
See also the SAM-version of that classic ticket: #9178.

@magnolia-k
Copy link

The code in this example can be compiled.

Also, the -Xexperimental option has been deprecated since Scala 2.13.0, so the issue itself can be closed.

@SethTisue SethTisue removed this from the Backlog milestone Jul 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants