-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #5107: disallow block as Apply.fun #5190
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 all commits
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 |
---|---|---|
|
@@ -40,11 +40,15 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { | |
def Super(qual: Tree, mixName: TypeName, inConstrCall: Boolean, mixinClass: Symbol = NoSymbol)(implicit ctx: Context): Super = | ||
Super(qual, if (mixName.isEmpty) untpd.EmptyTypeIdent else untpd.Ident(mixName), inConstrCall, mixinClass) | ||
|
||
def Apply(fn: Tree, args: List[Tree])(implicit ctx: Context): Apply = | ||
def Apply(fn: Tree, args: List[Tree])(implicit ctx: Context): Apply = { | ||
assert(fn.isInstanceOf[RefTree] || fn.isInstanceOf[GenericApply[_]]) | ||
ta.assignType(untpd.Apply(fn, args), fn, args) | ||
} | ||
|
||
def TypeApply(fn: Tree, args: List[Tree])(implicit ctx: Context): TypeApply = | ||
def TypeApply(fn: Tree, args: List[Tree])(implicit ctx: Context): TypeApply = { | ||
assert(fn.isInstanceOf[RefTree] || fn.isInstanceOf[GenericApply[_]]) | ||
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. Can we have nested 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. With named type arguments yes I think so 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. ... also with curried type lambdas. |
||
ta.assignType(untpd.TypeApply(fn, args), fn, args) | ||
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. You could try to do the same for TypeApply. 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. Yes, we could do that. I'm wondering how 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. You will probably not be able to. You could add the assertion to make sure. |
||
} | ||
|
||
def Literal(const: Constant)(implicit ctx: Context): Literal = | ||
ta.assignType(untpd.Literal(const)) | ||
|
@@ -181,8 +185,10 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { | |
def Alternative(trees: List[Tree])(implicit ctx: Context): Alternative = | ||
ta.assignType(untpd.Alternative(trees), trees) | ||
|
||
def UnApply(fun: Tree, implicits: List[Tree], patterns: List[Tree], proto: Type)(implicit ctx: Context): UnApply = | ||
def UnApply(fun: Tree, implicits: List[Tree], patterns: List[Tree], proto: Type)(implicit ctx: Context): UnApply = { | ||
assert(fun.isInstanceOf[RefTree] || fun.isInstanceOf[GenericApply[_]]) | ||
ta.assignType(untpd.UnApply(fun, implicits, patterns), proto) | ||
} | ||
|
||
def ValDef(sym: TermSymbol, rhs: LazyTree = EmptyTree)(implicit ctx: Context): ValDef = | ||
ta.assignType(untpd.ValDef(sym.name, TypeTree(sym.info), rhs), sym) | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2365,7 +2365,12 @@ class Typer extends Namer | |
} | ||
} else issueErrors() | ||
} | ||
else readaptSimplified(tpd.Apply(tree, args)) | ||
else tree match { | ||
case tree: Block => | ||
readaptSimplified(tpd.Block(tree.stats, tpd.Apply(tree.expr, args))) | ||
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. What if tree.expr is a block itself? This is handled by https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/transform/Splitter.scala 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. Just added an assert in |
||
case _ => | ||
readaptSimplified(tpd.Apply(tree, args)) | ||
} | ||
} | ||
addImplicitArgs(argCtx(tree)) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ import vulpix.TestConfiguration | |
class PatmatExhaustivityTest { | ||
val testsDir = "tests/patmat" | ||
// stop-after: patmatexhaust-huge.scala crash compiler | ||
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. Does it still crash the compiler with the new labelled blocks ? 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. Just tried locally, it works now. Edit: CI not happy, reverted. |
||
val options = List("-color:never", "-Ystop-after:splitter", "-Ycheck-all-patmat", "-classpath", TestConfiguration.basicClasspath) | ||
val options = List("-color:never", "-Ystop-after:crossCast", "-Ycheck-all-patmat", "-classpath", TestConfiguration.basicClasspath) | ||
|
||
private def compileFile(path: JPath) = { | ||
val stringBuffer = new StringWriter() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Test { | ||
inline def foo(x: Int = 5)(implicit y: Int): Int = | ||
if (x > 0) y * y | ||
else y + y | ||
|
||
implicit val m: Int = 7 | ||
|
||
(new Test).foo() | ||
} |
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 splitter source file was nod removed