Question about trait problem



I have a trait Rectangular

import java.awt.Point

public trait Rectangular {

  protected val upperLeft : Point
  protected val lowerRight : Point

  protected fun printBounds() {


and a class Rectangle that makes use of the Rectangular trait:

open class Rectangle(upperLeftParam: Point, lowerRightParam: Point) : Rectangular {   override var upperLeft = upperLeftParam   override var lowerRight = lowerRightParam

  fun foo() {

fun main(args: Array<String>) {
  var rect = Rectangle(Point(0, 5), Point(5, 0))

This compiles fine, but throws an exception when executed:

Exception in thread "main" java.lang.IllegalAccessError: Rectangle.getUpperLeft()Ljava/awt/Point;   at Rectangular$$TImpl.printBounds(Rectangular.kt:16)   at Rectangle.printBounds(Rectangle.kt)   at   at namespace$src$Rectangle$620803626.main(Rectangle.kt:22)   at namespace.main(Rectangular.kt)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)   at sun.reflect.NativeMethodAccessorImpl.invoke(   at sun.reflect.DelegatingMethodAccessorImpl.invoke(   at java.lang.reflect.Method.invoke(   at com.intellij.rt.execution.application.AppMain.main(

Am using IDEA IC-122.519 and Kotlin plugin   0.4.68. Funny thing is that it even won't go into the debugger. Am I doing something wrong here or is there a problem?


This is a bug, please report it to our tracker. Thanks!


Okay, here we go:


Please for this one. Traits are really cool. You need to have them, the sooner the more fun ... ;-)


Let's be fair: the only thing you can't do right now is have protected members in your traits. You can have almost as much fun having those members public. :)


I should have been more precise, I guess. Sorry about that. Looking forward to M4. This will be the real thing milestone release for me :-).