File tree Expand file tree Collapse file tree 5 files changed +11
-0
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 5 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,8 @@ object Inliner {
97
97
if tree.symbol.isExperimental then
98
98
Feature .checkExperimentalDef(tree.symbol, tree)
99
99
100
+ if tree.symbol.isConstructor then return tree // error already reported for the inline constructor definition
101
+
100
102
/** Set the position of all trees logically contained in the expansion of
101
103
* inlined call `call` to the position of `call`. This transform is necessary
102
104
* when lifting bindings from the expansion to the outside of the call.
Original file line number Diff line number Diff line change @@ -2164,6 +2164,8 @@ class Typer extends Namer
2164
2164
PrepareInlineable .registerInlineInfo(sym, rhsToInline)
2165
2165
2166
2166
if sym.isConstructor then
2167
+ if sym.is(Inline ) then
2168
+ report.error(" constructors cannot be `inline`" , ddef)
2167
2169
if sym.isPrimaryConstructor then
2168
2170
if sym.owner.is(Case ) then
2169
2171
for
Original file line number Diff line number Diff line change
1
+ class Bar (i : Int ):
2
+ inline def this () = this (0 ) // error
Original file line number Diff line number Diff line change
1
+ val bar = new Bar ()
Original file line number Diff line number Diff line change
1
+ class Bar (i : Int ):
2
+ transparent inline def this () = this (0 ) // error
3
+
4
+ val bar = Bar ()
You can’t perform that action at this time.
0 commit comments