Vijaykumar created GROOVY-7469:
----------------------------------

             Summary: ClassCastException in groovy 2.3.10. See description 
section for more information
                 Key: GROOVY-7469
                 URL: https://issues.apache.org/jira/browse/GROOVY-7469
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 2.3.10
            Reporter: Vijaykumar


Hi Team,

I'm facing an issue with groovy version 2.3.10. I'm doing the version upgrade 
from 2.2.2 to 2.3.10.

The existing code is working in groovy 2.2.2 and the same code throws an 
exception (ClassCastException) in groovy 2.3.10.

//FoodItem Class -- start
Class FoodItem extends Item 
{
        static Construct builder() {
        new Construct() 
        }
  static class Construct
  {
  Item.Construct build
  Construct() {
            build = new   Item.Construct() { }
   }
   FoodItem build() {
        new FoodItem (build.map)  // This line throws the classcastexception
    }
}

//FoodItem Class -- End

// Item class -- start
abstract class Item 
{
 protected TreeMap map
    protected Item() {
        this.map = [:]
    }
    protected Item(TreeMap map) {
        this.map = [:]
        if (map != null) {
            this.map = map
        }
    }
    protected Item(Map map) {
        this.map = [:]
        if (map != null) {
            this.map = new TreeMap(map)
        }
    }
    TreeMap getMap() { this.map }

abstract protected static class Construct {
 protected TreeMap map

        protected Construct() {
            this.map = [:]
        }

        protected Construct(Item item) {
            this.map = item.map as TreeMap
        }
}
// Item class -- End



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to