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

Regression in raw types #8244

Closed
scabug opened this issue Feb 6, 2014 · 6 comments
Closed

Regression in raw types #8244

scabug opened this issue Feb 6, 2014 · 6 comments

Comments

@scabug
Copy link

scabug commented Feb 6, 2014

See code: https://github.com/JetBrains/intellij-scala/blob/8d99d6dc00d29326a056cd46aef9c3a1746eac12/src/org/jetbrains/plugins/scala/lang/psi/impl/toplevel/ScEarlyDefinitionsImpl.scala#L71

On runtime I got:

java.lang.ClassCastException: org.jetbrains.plugins.scala.lang.psi.impl.statements.ScPatternDefinitionImpl cannot be cast to org.jetbrains.plugins.scala.lang.psi.api.toplevel.ScEarlyDefinitions
	at org.jetbrains.plugins.scala.lang.psi.impl.toplevel.ScEarlyDefinitionsImpl$$anonfun$members$1.apply(ScEarlyDefinitionsImpl.scala:71)
	at org.jetbrains.plugins.scala.lang.psi.impl.toplevel.ScEarlyDefinitionsImpl$$anonfun$members$1.apply(ScEarlyDefinitionsImpl.scala:70)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)

I can't attach compiled files, they are here: https://drive.google.com/file/d/0B21c1yb3Opowc21pVDJicm9JeVE/edit?usp=sharing

You can test it with our plugin sources, branch master.2.11

@scabug
Copy link
Author

scabug commented Feb 6, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8244?orig=1
Reporter: @Alefas
Affected Versions: 2.11.0-M8

@scabug
Copy link
Author

scabug commented Feb 6, 2014

@retronym said:
Changed in scala/scala@46e8ece

@scabug
Copy link
Author

scabug commented Feb 6, 2014

@retronym said (edited on Feb 6, 2014 4:05:27 PM UTC):
Before:

% (export V=f01e001~5; scala-hash $V -nc -classpath SDK/LedaSDK/lib/openapi.jar:SDK/LedaSDK/lib/annotations.jar:SDK/LedaSDK/lib/util.jar:out/cardea/production/ScalaCommunity )

scala> val tp = typeOf[org.jetbrains.plugins.scala.lang.psi.api.toplevel.ScEarlyDefinitions with org.jetbrains.plugins.scala.lang.psi.stubs.ScEarlyDefinitionsStub]
tp: $r.intp.global.Type = org.jetbrains.plugins.scala.lang.psi.api.toplevel.ScEarlyDefinitions with org.jetbrains.plugins.scala.lang.psi.stubs.ScEarlyDefinitionsStub

scala> val sym = tp.member(TermName("getChildrenStubs"))
sym: $r.intp.global.Symbol = method getChildrenStubs

scala> tp memberType sym
res0: $r.intp.global.Type = ()java.util.List[com.intellij.psi.stubs.StubElement[_ <: com.intellij.psi.PsiElement]]

scala> val tp = typeOf[org.jetbrains.plugins.scala.lang.psi.stubs.ScEarlyDefinitionsStub]
tp: $r.intp.global.Type = org.jetbrains.plugins.scala.lang.psi.stubs.ScEarlyDefinitionsStub

scala> val sym = tp.member(TermName("getChildrenStubs"))
sym: $r.intp.global.Symbol = method getChildrenStubs

scala> tp memberType sym
res0: $r.intp.global.Type = ()java.util.List[com.intellij.psi.stubs.StubElement[_ <: com.intellij.psi.PsiElement]]

After:

% (export V=f01e001~4; scala-hash $V -nc -classpath SDK/LedaSDK/lib/openapi.jar:SDK/LedaSDK/lib/annotations.jar:SDK/LedaSDK/lib/util.jar:out/cardea/production/ScalaCommunity )
scala> val tp = typeOf[org.jetbrains.plugins.scala.lang.psi.api.toplevel.ScEarlyDefinitions with org.jetbrains.plugins.scala.lang.psi.stubs.ScEarlyDefinitionsStub]
tp: $r.intp.global.Type = org.jetbrains.plugins.scala.lang.psi.api.toplevel.ScEarlyDefinitions with org.jetbrains.plugins.scala.lang.psi.stubs.ScEarlyDefinitionsStub

scala> tp.member(TermName("getChildrenStubs"))
res4: $r.intp.global.Symbol = method getChildrenStubs

scala> val sym = tp.member(TermName("getChildrenStubs"))
sym: $r.intp.global.Symbol = method getChildrenStubs

scala> tp memberType sym
res6: $r.intp.global.Type = ()java.util.List[com.intellij.psi.stubs.StubElement[org.jetbrains.plugins.scala.lang.psi.api.toplevel.ScEarlyDefinitions]]

scala> tp memberType sym
res1: $r.intp.global.Type = ()java.util.List[com.intellij.psi.stubs.StubElement[org.jetbrains.plugins.scala.lang.psi.api.toplevel.ScEarlyDefinitions]]

scala> val tp = typeOf[org.jetbrains.plugins.scala.lang.psi.stubs.ScEarlyDefinitionsStub]
tp: $r.intp.global.Type = org.jetbrains.plugins.scala.lang.psi.stubs.ScEarlyDefinitionsStub

scala> tp memberType sym
res2: $r.intp.global.Type = ()java.util.List[com.intellij.psi.stubs.StubElement[org.jetbrains.plugins.scala.lang.psi.api.toplevel.ScEarlyDefinitions]]

@scabug
Copy link
Author

scabug commented Feb 6, 2014

@retronym said:

scala> :javap -public org.jetbrains.plugins.scala.lang.psi.stubs.ScEarlyDefinitionsStub
Compiled from "ScEarlyDefinitionsStub.scala"
public interface org.jetbrains.plugins.scala.lang.psi.stubs.ScEarlyDefinitionsStub extends com.intellij.psi.stubs.StubElement{
}


scala> :javap -public com.intellij.psi.stubs.StubElement
Compiled from "StubElement.java"
public interface com.intellij.psi.stubs.StubElement extends com.intellij.psi.stubs.Stub{
    public abstract com.intellij.psi.stubs.IStubElementType getStubType();
    public abstract com.intellij.psi.stubs.StubElement getParentStub();
    public abstract java.util.List getChildrenStubs();
    public abstract com.intellij.psi.stubs.StubElement findChildStubByType(com.intellij.psi.stubs.IStubElementType);
    public abstract com.intellij.psi.PsiElement getPsi();
    public abstract com.intellij.psi.PsiElement[] getChildrenByType(com.intellij.psi.tree.IElementType, com.intellij.psi.PsiElement[]);
    public abstract com.intellij.psi.PsiElement[] getChildrenByType(com.intellij.psi.tree.TokenSet, com.intellij.psi.PsiElement[]);
    public abstract com.intellij.psi.PsiElement[] getChildrenByType(com.intellij.psi.tree.IElementType, com.intellij.util.ArrayFactory);
    public abstract com.intellij.psi.PsiElement[] getChildrenByType(com.intellij.psi.tree.TokenSet, com.intellij.util.ArrayFactory);
    public abstract com.intellij.psi.PsiElement getParentStubOfType(java.lang.Class);
}

@scabug
Copy link
Author

scabug commented Feb 7, 2014

@retronym said:
Minimized:

javac Raw.java -d . && scalac-hash v2.10.3 -Xprint:typer Client.scala
[[syntax trees at end of                     typer]] // Client.scala
package <empty> {
  abstract trait X extends Raw[X];
  class Client extends scala.AnyRef {
    def <init>(): Client = {
      Client.super.<init>();
      ()
    };
    def c(s: X): Raw[_] = s.raw()
  }
}

master.2.11 ~/code/intellij-scala javac Raw.java -d . && scalac-hash v2.11.0-M7 -Xprint:typer Client.scala
[[syntax trees at end of                     typer]] // Client.scala
package <empty> {
  abstract trait X extends Raw[X];
  class Client extends scala.AnyRef {
    def <init>(): Client = {
      Client.super.<init>();
      ()
    };
    def c(s: X): Raw[X] = s.raw()
  }
}

master.2.11 ~/code/intellij-scala tail Raw.java Client.scala
==> Raw.java <==
public class Raw<T>{
	public Raw raw() { return null; }
}

==> Client.scala <==
trait X extends Raw[X]

class Client {
  def c(s: X) = s.raw
}

@scabug
Copy link
Author

scabug commented Feb 7, 2014

@retronym said (edited by @adriaanm on Feb 13, 2014 4:43:34 AM UTC):
scala/scala#3519

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants