You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current semantics of inline override is inconsistent and confusing.
Current state
classGreeting {
defgreet(name: String):String="Greetings "+ name
}
classHelloextendsGreeting {
inlineoverridedefgreet(name: String):String="Hello "+ name
}
objectApp {
valgreeting:Greeting=newGreetingvalhello1:Hello=newHellovalhello2:Greeting= hello1
println(greeting.greet("World")) // prints: Greetings World
println(hello1.greet("World")) // prints: Hello World// Inlined Hello.greet directly
println(hello2.greet("World")) // prints: Greetings World// Not inlined as it is statically calling Greeting.greet, so far so good// It should have dynamically call Hello.greet, but inline method are erased!
}
Semantically coherent version
objectApp {
valgreeting:Greeting=newGreetingvalhello1:Hello=newHellovalhello2:Greeting= hello1
println(greeting.greet("World")) // prints: Greetings World
println(hello1.greet("World")) // prints: Hello World// Inlined as we call Hello.greet directly
println(hello2.greet("World")) // prints: Hello World// Not inlined as it is statiacally calling Greeting.greet.// Dynamically calls Hello.greet
}
How to make this happen
classHelloextendsGreeting {
inlineoverridedefgreet(name: String):String="Hello "+ name
}
should become
classHelloextendsGreeting {
overridedefgreet(name: String):String="Hello "+ name
}
The current semantics of
inline override
is inconsistent and confusing.Current state
Semantically coherent version
How to make this happen
should become
and
would become
The text was updated successfully, but these errors were encountered: