Open b-studios opened 1 week ago
Here is gpt4o:
In the build.sbt, ensure that type parameters are handled correctly.
class Namer {
def defineTypeParameters(params: List[TypeParameter], scope: Scope): Unit = {
params.foreach { param =>
scope.define(param)
}
}
def enterScope[T](scope: Scope)(block: => T): T = {
val previousScope = currentScope
currentScope = scope
try {
block
} finally {
currentScope = previousScope
}
}
}
Create tests to ensure type parameters are scoped correctly.
test("Type parameters are scoped locally") {
val fooScope = new Scope()
val bazScope = new Scope()
enterScope(fooScope) {
defineTypeParameters(List("T"), fooScope)
assert(fooScope.lookup("T").isDefined)
}
enterScope(bazScope) {
defineTypeParameters(List("T"), bazScope)
assert(bazScope.lookup("T").isDefined)
}
}
Sorry @unnir, not even close :)
should type check, but reports:
The scope of
T
is probably not delimited correctly inNamer
and hence it introduces a file-global typeT
.