-
Notifications
You must be signed in to change notification settings - Fork 10
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
Can't use BodyInfo in Scrimmage #403
Comments
Why do you need As far as polymorphishm goes, |
This really needs to be solved ASAP, as it really slows down the development process. Polymorphism in general works as this example shows: def testPolymorphism[T](array: Array[T]): Boolean = true
def minimalExample() = {
val trees: Array[TreeInfo] = rc.senseNearbyTrees()
assert(testPolymorphism(array)))
// No exception whatsoever
} But there is something wrong as this example shows: def minimalExample() = {
System.out.println(
rc.senseNearbyTrees() ++ rc.senseNearbyRobots() // InstrumentationException!
)
// This also throws an exception
(rc.senseNearbyTrees(): Array[BodyInfo]) ++ (rc.senseNearbyRobots(): Array[BodyInfo])
// The following work fine
(rc.senseNearbyTrees(): Array[TreeInfo]) ++ (rc.senseNearbyRobots(): Array[TreeInfo])
(rc.senseNearbyTrees(): Seq[BodyInfo]) ++ (rc.senseNearbyRobots(): Seq[BodyInfo])
} Running it results in this stack trace:
|
These are really two separate issues. For @revalo's issue: Make sure your code doesn't rely on (even import) any For @omelkonian's issue: To fix this, the devs need to whitelist object RobotPlayer {
def run(rc: RobotController) {
val things = rc.senseNearbyRobots().toList ++ rc.senseNearbyTrees().toList // this works
println(things)
}
} Explanation: For historical reasons, all container types except arrays undergo type erasure. A side effect of this is that in Java, generic arrays Edit: reformatted some things |
Can't use Polymorphism.
Edit: mistake in title.
The text was updated successfully, but these errors were encountered: