File tree 6 files changed +20
-2
lines changed
compiler/src/dotty/tools/dotc
6 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ public enum ErrorMessageID {
125
125
UnableToEmitSwitchID ,
126
126
MissingCompanionForStaticID ,
127
127
PolymorphicMethodMissingTypeInParentID ,
128
+ ParamsNoInlineID ,
128
129
;
129
130
130
131
public int errorNumber () {
Original file line number Diff line number Diff line change @@ -2069,4 +2069,11 @@ object messages {
2069
2069
| $rsym does not override any method in $parentSym. Structural refinement does not allow for
2070
2070
|polymorphic methods. """
2071
2071
}
2072
+
2073
+ case class ParamsNoInline (owner : Symbol )(implicit ctx : Context )
2074
+ extends Message (ParamsNoInlineID ) {
2075
+ val kind = " Syntax"
2076
+ val msg = hl """ ${" inline" } modifier cannot be used for a ${owner.showKind} parameter """
2077
+ val explanation = " "
2078
+ }
2072
2079
}
Original file line number Diff line number Diff line change @@ -341,6 +341,9 @@ object Checking {
341
341
if (! ok && ! sym.is(Synthetic ))
342
342
fail(i " modifier ` $flag` is not allowed for this definition " )
343
343
344
+ if (sym.is(Inline ) && ((sym.is(ParamAccessor ) && sym.owner.isClass) || sym.is(TermParam ) && sym.owner.isClassConstructor))
345
+ fail(ParamsNoInline (sym.owner))
346
+
344
347
if (sym.is(ImplicitCommon )) {
345
348
if (sym.owner.is(Package ))
346
349
fail(TopLevelCantBeImplicit (sym))
Original file line number Diff line number Diff line change @@ -925,7 +925,7 @@ class Namer { typer: Typer =>
925
925
}
926
926
}
927
927
928
- addAnnotations(denot.symbol, original)
928
+ addAnnotations(denot.symbol, original)
929
929
930
930
val selfInfo =
931
931
if (self.isEmpty) NoType
Original file line number Diff line number Diff line change
1
+ class Foo (inline val i : Int ) // error
2
+ case class Foo2 (inline val i : Int ) // error
3
+ class Foo3 (inline val i : Int ) extends AnyVal // error
4
+ trait Foo4 (inline val i : Int ) // error
5
+ class Foo5 () {
6
+ def this (inline x : Int ) = this () // error
7
+ }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ object Test {
7
7
8
8
inline inline val twice = 30 // error: repeated modifier
9
9
10
- class C (inline x : Int , private inline val y : Int ) {
10
+ class C (inline x : Int , private inline val y : Int ) { // error // error
11
11
inline val foo : Int // error: abstract member may not be inline
12
12
inline def bar : Int // error: abstract member may not be inline
13
13
}
You can’t perform that action at this time.
0 commit comments