-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix more problems detected by fuzzing in #4389 #4411
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
Changes from 7 commits
09eb5f7
77f75b7
297c216
5597dd0
de58653
a6ba33b
64e36f1
f7c46af
f8f5176
5ad42d1
c3bd95a
5f9f3a7
690321d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1447,7 +1447,11 @@ class Typer extends Namer | |
assignType(cpy.TypeDef(tdef)(name, rhs1), sym) | ||
} | ||
|
||
def typedClassDef(cdef: untpd.TypeDef, cls: ClassSymbol)(implicit ctx: Context) = track("typedClassDef") { | ||
def typedClassDef(cdef: untpd.TypeDef, cls: ClassSymbol)(implicit ctx: Context): Tree = track("typedClassDef") { | ||
if (!cls.info.isInstanceOf[ClassInfo]) { | ||
assert(ctx.reporter.errorsReported) | ||
return cdef.withType(UnspecifiedErrorType) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think ideally we should have a way to recursively set the type of the tree children to maintain the invariant that a typed tree only contains typed trees. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, yes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, that's not so easy. Sometimes, there's simply no way to proceed. And we cannot just assign an ErrorType, because a lot of trees are not typed trees, so we'd have to replace them with something else. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess they could be replaced by ErrorTrees. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In fact, maybe cdef should just be replaced by an ErrorTree since it's unusable anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, yes. Let's do that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm wait. What do you mean by ErrorTree? We only have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, we can replace it with an EmptyTree instead. |
||
} | ||
val TypeDef(name, impl @ Template(constr, parents, self, _)) = cdef | ||
val superCtx = ctx.superCallContext | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
trait x0[T] { self: x0 => } // error | ||
|
||
trait x1[T] { self: (=> String) => } // error | ||
|
||
trait x2[T] { self: ([X] => X) => } // error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package x0 { | ||
case class x0 // error // error | ||
} | ||
package x0 | ||
class x0 // error // error |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
trait x0[] // error | ||
trait x1[x1 <:x0] | ||
extends x1[ // error |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
object x0 { | ||
{ | ||
val x1 x0 // error | ||
object x1 // error // error |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package x0 | ||
class x0 { | ||
def x1 = | ||
x2 match // error | ||
] // error | ||
case x3[] => x0 // error // error // error // error |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class x0[x0] { | ||
val x1 : x0 | ||
} | ||
trait x3 extends x0 { | ||
x1 = 0 object // error // error |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
trait x0[] { x0: x0 => } | ||
class x0[x1] extends x0[x0 x0] x2 x0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
trait x0 { | ||
class x1 (x1:x0 | ||
{ | ||
type x1 <: List[x1 <: // error // error |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
object Test { | ||
|
||
class C { | ||
|
||
class I | ||
|
||
} | ||
|
||
trait T | ||
|
||
val x: C { type I <: T } = ??? // direct refinement of class member | ||
|
||
val y: x.I = ??? | ||
|
||
} | ||
|
||
class B { | ||
class C { | ||
type I | ||
} | ||
trait T | ||
|
||
type CC <: C | ||
|
||
val x: CC { type I <: T } = ??? | ||
} | ||
|
||
object Test2 extends B { | ||
|
||
class CC extends C { class I } | ||
|
||
val y: x.I = ??? // indirect refinement of class member | ||
|
||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth explicitly checking that an error happened like other commits in this PR do, e.g.:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The given type might be higher-kinded (in fact that's what it was in the test) but this would be detected only later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, in that case maybe just add a comment explaining that non-value types self can only happen with erroneous code? Otherwise readers of this code might be puzzled.