-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Decompiler: empty parens, type variance #5729
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -590,8 +590,9 @@ trait Printers | |
else if (flags.is(Flags.Abstract)) this += highlightKeyword("abstract class ", color) += highlightTypeDef(name, color) | ||
else this += highlightKeyword("class ", color) += highlightTypeDef(name, color) | ||
|
||
val typeParams = stats.collect { case IsTypeDef(targ) => targ }.filter(_.symbol.isTypeParam).zip(targs) | ||
if (!flags.is(Flags.Object)) { | ||
printTargsDefs(targs) | ||
printTargsDefs(typeParams) | ||
val it = argss.iterator | ||
while (it.hasNext) | ||
printArgsDefs(it.next()) | ||
|
@@ -606,14 +607,19 @@ trait Printers | |
if (parents1.nonEmpty) | ||
this += highlightKeyword(" extends ", color) | ||
|
||
def printParent(parent: TermOrTypeTree): Unit = parent match { | ||
def printParent(parent: TermOrTypeTree, needEmptyParens: Boolean = false): Unit = parent match { | ||
case IsTypeTree(parent) => | ||
printTypeTree(parent) | ||
case IsTerm(Term.TypeApply(fun, targs)) => | ||
printParent(fun) | ||
case IsTerm(Term.Apply([email protected](_,_), args)) => | ||
printParent(fun, true) | ||
if (!args.isEmpty || needEmptyParens) | ||
inParens(printTrees(args, ", ")) | ||
case IsTerm(Term.Apply(fun, args)) => | ||
printParent(fun) | ||
inParens(printTrees(args, ", ")) | ||
if (!args.isEmpty || needEmptyParens) | ||
inParens(printTrees(args, ", ")) | ||
case IsTerm(Term.Select(Term.New(tpt), _)) => | ||
printTypeTree(tpt) | ||
case IsTerm(parent) => | ||
|
@@ -691,7 +697,7 @@ trait Printers | |
case IsTypeDef(tdef @ TypeDef(name, rhs)) => | ||
printDefAnnotations(tdef) | ||
this += highlightKeyword("type ", color) | ||
printTargDef(tdef, isMember = true) | ||
printTargDef((tdef, tdef), isMember = true) | ||
|
||
case IsValDef(vdef @ ValDef(name, tpt, rhs)) => | ||
printDefAnnotations(vdef) | ||
|
@@ -754,7 +760,7 @@ trait Printers | |
printProtectedOrPrivate(ddef) | ||
|
||
this += highlightKeyword("def ", color) += highlightValDef((if (isConstructor) "this" else name), color) | ||
printTargsDefs(targs) | ||
printTargsDefs(targs.zip(targs)) | ||
val it = argss.iterator | ||
while (it.hasNext) | ||
printArgsDefs(it.next()) | ||
|
@@ -1125,13 +1131,13 @@ trait Printers | |
this | ||
} | ||
|
||
def printTargsDefs(targs: List[TypeDef]): Unit = { | ||
def printTargsDefs(targs: List[(TypeDef, TypeDef)], isDef:Boolean = true): Unit = { | ||
if (!targs.isEmpty) { | ||
def printSeparated(list: List[TypeDef]): Unit = list match { | ||
def printSeparated(list: List[(TypeDef, TypeDef)]): Unit = list match { | ||
case Nil => | ||
case x :: Nil => printTargDef(x) | ||
case x :: Nil => printTargDef(x, isDef = isDef) | ||
case x :: xs => | ||
printTargDef(x) | ||
printTargDef(x, isDef = isDef) | ||
this += ", " | ||
printSeparated(xs) | ||
} | ||
|
@@ -1140,9 +1146,19 @@ trait Printers | |
} | ||
} | ||
|
||
def printTargDef(arg: TypeDef, isMember: Boolean = false): Buffer = { | ||
this += arg.name | ||
arg.rhs match { | ||
def printTargDef(arg: (TypeDef, TypeDef), isMember: Boolean = false, isDef:Boolean = true): Buffer = { | ||
val (argDef, argCons) = arg | ||
|
||
if (isDef) { | ||
if (argDef.symbol.flags.is(Flags.Covariant)) { | ||
this += highlightValDef("+", color) | ||
} else if (argDef.symbol.flags.is(Flags.Contravariant)) { | ||
this += highlightValDef("-", color) | ||
} | ||
} | ||
|
||
this += argCons.name | ||
argCons.rhs match { | ||
case IsTypeBoundsTree(rhs) => printBoundsTree(rhs) | ||
case rhs @ WildcardTypeTree() => | ||
printTypeOrBound(rhs.tpe) | ||
|
@@ -1412,7 +1428,7 @@ trait Printers | |
printTypeTree(result) | ||
|
||
case TypeTree.LambdaTypeTree(tparams, body) => | ||
printTargsDefs(tparams) | ||
printTargsDefs(tparams.zip(tparams), isDef = false) | ||
this += highlightTypeDef(" => ", color) | ||
printTypeOrBoundsTree(body) | ||
|
||
|
@@ -1576,7 +1592,10 @@ trait Printers | |
val Annotation(ref, args) = annot | ||
this += "@" | ||
printTypeTree(ref) | ||
inParens(printTrees(args, ", ")) | ||
if (args.isEmpty) | ||
this | ||
else | ||
inParens(printTrees(args, ", ")) | ||
} | ||
|
||
def printDefAnnotations(definition: Definition): Buffer = { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
/** Decompiled from out/posTestFromTasty/pos/i4678/Foo.tasty */ | ||
class Foo() { | ||
val x: scala.Int = (1: @annot1() @annot2() @annot3() @annot4() @annot5()) | ||
val x: scala.Int = (1: @annot1 @annot2 @annot3 @annot4 @annot5) | ||
} | ||
/** Decompiled from out/posTestFromTasty/pos/i4678/annot1.tasty */ | ||
class annot1() extends scala.annotation.Annotation() | ||
class annot1() extends scala.annotation.Annotation | ||
/** Decompiled from out/posTestFromTasty/pos/i4678/annot2.tasty */ | ||
class annot2() extends scala.annotation.Annotation() | ||
class annot2() extends scala.annotation.Annotation | ||
/** Decompiled from out/posTestFromTasty/pos/i4678/annot3.tasty */ | ||
class annot3() extends scala.annotation.Annotation() | ||
class annot3() extends scala.annotation.Annotation | ||
/** Decompiled from out/posTestFromTasty/pos/i4678/annot4.tasty */ | ||
class annot4() extends scala.annotation.Annotation() | ||
class annot4() extends scala.annotation.Annotation | ||
/** Decompiled from out/posTestFromTasty/pos/i4678/annot5.tasty */ | ||
class annot5() extends scala.annotation.Annotation() | ||
class annot5() extends scala.annotation.Annotation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
/** Decompiled from out/posTestFromTasty/pos/simpleAnnot/Foo.class */ | ||
/** Decompiled from out/posTestFromTasty/pos/simpleAnnot/Foo.tasty */ | ||
class Foo() { | ||
@annot() type A = scala.Int | ||
@annot() val a: scala.Int = scala.Predef.??? | ||
val b: scala.Int @annot() = scala.Predef.??? | ||
def c(x: scala.Int): scala.Int = (x: @annot()) | ||
@annot type A = scala.Int | ||
@annot val a: scala.Int = scala.Predef.??? | ||
val b: scala.Int @annot = scala.Predef.??? | ||
def c(x: scala.Int): scala.Int = (x: @annot) | ||
} | ||
/** Decompiled from out/posTestFromTasty/pos/simpleAnnot/annot.class */ | ||
class annot() extends scala.annotation.Annotation() | ||
/** Decompiled from out/posTestFromTasty/pos/simpleAnnot/annot.tasty */ | ||
class annot() extends scala.annotation.Annotation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
/** Decompiled from out/posTestFromTasty/pos/simpleCaseClass-1/A.class */ | ||
/** Decompiled from out/posTestFromTasty/pos/simpleCaseClass-1/A.tasty */ | ||
case class A() { | ||
override def hashCode(): scala.Int = 1914112431 | ||
override def equals(x$0: scala.Any): scala.Boolean = A.this.eq(x$0.asInstanceOf[java.lang.Object]).||(x$0 match { | ||
case x$0: A @scala.unchecked() => | ||
case x$0: A @scala.unchecked => | ||
true | ||
case _ => | ||
false | ||
}) | ||
override def toString(): java.lang.String = scala.runtime.ScalaRunTime._toString(A.this) | ||
override def canEqual(that: scala.Any): scala.Boolean = that.isInstanceOf[A @scala.unchecked()] | ||
override def canEqual(that: scala.Any): scala.Boolean = that.isInstanceOf[A @scala.unchecked] | ||
override def productArity: scala.Int = 0 | ||
override def productPrefix: java.lang.String = "A" | ||
override def productElement(n: scala.Int): scala.Any = n match { | ||
case _ => | ||
throw new java.lang.IndexOutOfBoundsException(n.toString()) | ||
} | ||
} | ||
object A extends scala.Function0[A] | ||
object A extends scala.Function0[A] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
/** Decompiled from out/posTestFromTasty/pos/simpleCaseObject/foo/Foo.class */ | ||
/** Decompiled from out/posTestFromTasty/pos/simpleCaseObject/foo/Foo.tasty */ | ||
package foo { | ||
case object Foo { | ||
override def hashCode(): scala.Int = 1045991777 | ||
override def toString(): java.lang.String = "Foo" | ||
override def canEqual(that: scala.Any): scala.Boolean = that.isInstanceOf[foo.Foo.type @scala.unchecked()] | ||
override def canEqual(that: scala.Any): scala.Boolean = that.isInstanceOf[foo.Foo.type @scala.unchecked] | ||
override def productArity: scala.Int = 0 | ||
override def productPrefix: java.lang.String = "Foo" | ||
override def productElement(n: scala.Int): scala.Any = n match { | ||
case _ => | ||
throw new java.lang.IndexOutOfBoundsException(n.toString()) | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/** Decompiled from out/posTestFromTasty/pos/simpleClass-2/foo/A.class */ | ||
/** Decompiled from out/posTestFromTasty/pos/simpleClass-2/foo/A.tasty */ | ||
package foo { | ||
class A() extends foo.B() | ||
class A() extends foo.B | ||
} | ||
/** Decompiled from out/posTestFromTasty/pos/simpleClass-2/foo/B.class */ | ||
/** Decompiled from out/posTestFromTasty/pos/simpleClass-2/foo/B.tasty */ | ||
package foo { | ||
class B() | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/** Decompiled from out/posTestFromTasty/pos/simpleClass/foo/A.class */ | ||
/** Decompiled from out/posTestFromTasty/pos/simpleClass/foo/A.tasty */ | ||
package foo { | ||
class A() | ||
} | ||
/** Decompiled from out/posTestFromTasty/pos/simpleClass/foo/B.class */ | ||
/** Decompiled from out/posTestFromTasty/pos/simpleClass/foo/B.tasty */ | ||
package foo { | ||
class B() extends foo.A() | ||
class B() extends foo.A | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
/** Decompiled from out/posTestFromTasty/pos/simpleSuper/foo/A.class */ | ||
/** Decompiled from out/posTestFromTasty/pos/simpleSuper/foo/A.tasty */ | ||
package foo { | ||
class A() { | ||
def foo: scala.Int = 1 | ||
} | ||
} | ||
/** Decompiled from out/posTestFromTasty/pos/simpleSuper/foo/B.class */ | ||
/** Decompiled from out/posTestFromTasty/pos/simpleSuper/foo/B.tasty */ | ||
package foo { | ||
trait B() extends java.lang.Object { | ||
def foo: scala.Int = 2 | ||
} | ||
} | ||
/** Decompiled from out/posTestFromTasty/pos/simpleSuper/foo/C.class */ | ||
/** Decompiled from out/posTestFromTasty/pos/simpleSuper/foo/C.tasty */ | ||
package foo { | ||
class C() extends foo.A() with foo.B { | ||
class C() extends foo.A with foo.B { | ||
override def foo: scala.Int = super.foo.+(super[B].foo) | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/** Decompiled from out/posTestFromTasty/pos/t116/C.class */ | ||
/** Decompiled from out/posTestFromTasty/pos/t116/C.tasty */ | ||
class C() { | ||
def this(x: scala.Int) = { | ||
this() | ||
class D() extends C() | ||
class D() extends C | ||
() | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.